package org.millioncall.yueyoga.admin.export;

import java.util.List;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.millioncall.yueyoga.admin.model.LiftClubRecord;

public class LiftclubExportTemplate extends AbstractExcelExportTemplate {
	private List<LiftClubRecord> records;
	String[] titles = new String[] { "主题", "状态", "老师", "负责人", "场地", "开始时间", "结束时间" };
	public LiftclubExportTemplate(List<LiftClubRecord> records) {
		this.records = records;
	}

	@Override
	public String[] getSheetNames() {
		return new String[] { "活动信息表" };
	}

	@Override
	public String[][] getTitles() {
		return new String[][] { titles };
	}

	@Override
	protected void buildBody(int sheetIndex) {
		Sheet sheet = getSheet(sheetIndex);
		int startIndex = this.getBodyStartIndex(sheetIndex);
		for (int i = 0; i < this.records.size(); i++) {
			LiftClubRecord record = this.records.get(i);
			Row row = sheet.createRow(i + startIndex);
			row.setHeight((short) 300);
			int index = 0;
		    String status = "";
		    String stat = record.getStatus();
		    if(stat == null){
		    	status = "";
		    }else{
		    	status = record.getStatus().toString();
		    }
		    if("0".equals(status)){
		    	status = "准备中";
		    }else if("1".equals(status)){
		    	status = "进行中";
		    }else if("2".equals(status)){
		    	status = "活动结束";
		    }else if("3".equals(status)){
		    	status = "活动取消";
		    }
			createStyledCell(row, index++, record.getName()==null?"":record.getName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, status, this.bodyRowStyle);
			createStyledCell(row, index++, record.getMainTeacher()==null?"":record.getMainTeacher().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getOfficer()==null?"":record.getOfficer().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getPlace()==null?"":record.getPlace().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getStartdate()==null?"":record.getStartdate().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getEnddate()==null?"":record.getEnddate().toString(), this.bodyRowStyle);
		}
	}

	@Override
	public String[] getCaptions() {
		return new String[] { "活动信息表" };
	}
}
